package com.grsu.phonestation.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.grsu.phonestation.dao.UserActiveDAO;
import com.grsu.phonestation.domain.Client;
import com.grsu.phonestation.domain.UserActive;
import com.grsu.phonestation.service.UserActiveService;

@Service
@Transactional
public class UserActiveServiceImpl<UA extends UserActive> implements UserActiveService<UA> {

	@Autowired
	@Qualifier("userActiveDAOImpl")
	private UserActiveDAO<UA> userActiveDAO;
	
	public UserActiveDAO<UA> getDao(){
		return userActiveDAO;
	}
	
	@Override
	public void addUserActive(UA userActive) {
		getDao().save(userActive);

	}

	@Override
	public void editUserActive(UA userActive) {
		getDao().update(userActive);

	}

	@Override
	public void removeUserActive(int userActiveId) {
		getDao().remove(userActiveId);

	}

	@Override
	public List<UA> listUserActivesClientForPeriod(String user,
			String beginPeriod, String endPeriod) {
		List<UA> userActives = getDao().listActiveClientForPeriod(user, beginPeriod, endPeriod);
		return userActives;

	}

	@Override
	public List<UA> listUserActives() {
		List<UA> userActives = getDao().findAll();
		return userActives;

	}

	@Override
	public List<UA> getUnReplayActiveClient(Client client) {
		List<UA> userActives = getDao().getUnReplayActiveClient(client);
		return userActives;

	}

	@Override
	public double getSumUnReplayActiveClient(Client client) {
		return getDao().getSumUnReplayActiveClient(client);
	}

	@Override
	public List<Client> getClientsHaveUnReplayActive(){
		List<Client> clients = getDao().getClientsHaveUnReplayActive();
		return clients;
	}

	@Override
	public List<UA> getUserActiveClient(Client client) {
		List<UA> userActives = getDao().getUserActiveClient(client);
		return userActives;
	}

}
